<script>
function bersihkan() {
var tagDt = document.getElementById('tarea');
tagDt.value = '';
}
function rubah() {
var tagDt = document.getElementById('tarea');
var dtTag = tagDt.value;
dtTag = dtTag.replace(/&/g,"&amp;");
dtTag = dtTag.replace(/'/g,"&#039;");
dtTag = dtTag.replace(/"/g,"&quot;");
dtTag = dtTag.replace(/</g,"&lt;");
dtTag = dtTag.replace(/>/g,"&gt;");
tagDt.value = dtTag ;
};
</script>
<textarea cols="36" rows="5" id="tarea"></textarea><br/>
<button onclick="rubah();" type="button">Convert</button>
<button onclick="bersihkan();" type="button">Clear</button>